package net.bithappens.hnqe.query;

import java.util.Arrays;

import net.bithappens.hnqe.IllegalParamException;

public class Link extends QueryTree{

	public enum MatchType{EXACTMATCH, ANYCONNECTION}
	
	private Relation relation;
	
	private RelationMember[] members;
	
	private MatchType matchType;
	
	public Link( Relation relation, MatchType matchType, RelationMember... members) throws IllegalParamException{
		if(relation == null){
			throw new IllegalParamException("The Relation object must not be null");
		}
		
		if(matchType == null){
			throw new IllegalParamException("The MatchType object must not be null");
		}
		
		if(members != null && members.length != 0){
			for(RelationMember member : members){
				if(member == null){
					throw new IllegalParamException("NULL values for the RelationMember parameters are not allowes");
				}
			}
		} else {
			throw new IllegalParamException("The RelationMember object must not be null or empty");
		}
		
		this.matchType = matchType;
		this.relation = relation;
		this.members = members;
	}


	
	
	public MatchType getMatchType() {
		return matchType;
	}

	public Relation getRelation() {
		return relation;
	}

	public RelationMember[] getMembers() {
		return members;
	}




	@Override
	public String toString() {
		return "Link [matchType=" + matchType + ", relation=" + relation + ", members=" + Arrays.toString(members) + "]";
	}
}
